#ifndef _MATRIX_GRAPH_H_
#define _MATRIX_GRAPH_H_

#include "AbstractGraph.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <utility>

class MatrixGraph : public AbstractGraph{
private:
	std::vector<std::vector<bool> > matrix;
public:
	const bool getEdge(int fromVertex, int toVertex) const {
		return matrix[fromVertex][toVertex];
	}
	void setEdge(int fromVertex, int toVertex){
		matrix[fromVertex][toVertex] = true;
	}
	void readGraph(int vertexNum, int edgesNum, const std::vector<std::pair<int, int> >& edgesList){
		setVertexNum(vertexNum);
		setEdgesNum(edgesNum);
		std::vector<bool> forBuilding;
		forBuilding.assign(getVertexNum(), 0);
		matrix.assign(getVertexNum(), forBuilding);
		for (int currentEdge = 0; currentEdge < getEdgesNum(); ++currentEdge){
			setEdge(edgesList[currentEdge].first, edgesList[currentEdge].second);
		}
	}
	std::vector<int> getAdjacentList(int inputVertex){
		std::vector<int> adjacentList;
		for (int currentVertex = 0; currentVertex < getVertexNum(); ++currentVertex){
			if (inputVertex != currentVertex && getEdge(inputVertex, currentVertex)){
				adjacentList.push_back(currentVertex);
			}
		}
		return adjacentList;
	}
	virtual ~MatrixGraph(){}
};

#endif
